#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
int date(int year, int month)
{
    int arr[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if (month == 2 && (year % 4 == 0 && year % 100 != 0 || year % 400 == 0))
    {
        return arr[month] + 1;
    }
    else
    {
        return arr[month];
    }
}
int main() {
    int year;
    int n;
    int month=1;
    while (scanf("%d%d", &year, &n) != EOF)
    {
        int month = 1;
        while (n > date(year, month))
        {
            if (n > date(year, month))
            {
                n -= date(year, month);
                month++;
            }
            if (month > 12) {
                month = 1;
                year++;
            }
            if (n == 0) {
                month--;
                n = date(year, month);
            }
        }
        printf("%04d-%02d-%02d", year, month, n);
        printf("\n");
    }
}